<template>
	<view class="dynamic">
		<!-- 顶部作者栏 -->
		<nav-bars class="d_auth" backState="1000" bgColor="#fff" fontColor="#000">
			<view class="d_aCan" slot="default">
				<view class="d_aHead" v-if="userdata.avatar"><image :src="userdata.avatar.path"></image></view>
				<view class="d_aHead" v-else><image src="https://manager.ryz1620.com/static/my/avator.png"></image></view>
				<view class="d_aName omit-1" v-if="userdata.username">{{ userdata.username }}</view>
				<view class="d_aName omit-1" v-else>*****</view>
				<view class="d_guanzhu" @click="FollowUser(userdata.id)" :style="{ background: isFocus == 0 ? '#FFD425' : '#f6f7fb', color: isFocus == 0 ? '#232323' : '#939393' }">
					{{ isFocus == 0 ? '关注' : '已关注' }}
				</view>
			</view>
		</nav-bars>

		<!-- banner -->
		<view class="d_banner" v-if="info.type == 0">
			<swiper class="swiper" autoplay interval="4200" duration="300"  @change="bannerChange">
				<swiper-item v-for="(item, index) in media" :key="index" @click="preview(index, media)">
					<view class="d_bItem"><image  :src="item.path" mode="widthFix"></image></view>
				</swiper-item>
			</swiper>
			<view class="g_bDots">
				<view class="g_bDot" :class="{ active: bannerIndex === index }" v-for="(item, index) in media" :key="index"><view class="g_bIcon"></view></view>
			</view>
			<!-- <view style="position: absolute;top: 20rpx;right: 32rpx;padding:12rpx 23rpx ;background: rgba(0,0,0,.5);border-radius: 36rpx;font-weight: 500;color: #FFFFFF;">
				{{ bannerIndex + 1 + '/' + media.length }}
			</view> -->
		</view>
		<!-- 视频 -->
		<view class="playvideo" v-if="info.type == 1"><video style="width: 100%;" id="myVideo" :autoplay="true" :src="media[0].path" controls></video></view>

		<!-- 内容 -->
		<view class="d_content">
			<view class="S_stop" v-if="info.store_id>0" @tap="toPageurl(info.store.id)">
				<view class="S_Head">
					<view class="S_Image"><image :src="info.store.store_logo.path ? info.store.store_logo.path : '../../../../static/my/toux.png'"></image></view>
					<view class="S_stopName">{{ info.store.store_name ? info.store.store_name : '*****' }}</view>
				</view>
				<text class="iconfont icon-more iconfontMore"></text>
			</view>
			<view class="S_title">{{ info.title }}</view>
			<view class="d_cTime" v-if="create_time">{{ create_time | formatDate }}</view>
			<view class="d_cText">{{ info.content }}</view>
			<!-- <view class="d_cTags">
				<view class="d_cTag">
					<view class="d_cIcon"><image src="/static/common/icon_topic.png"></image></view>
					<text>{{ info.title }}</text>
				</view>
			</view> -->
			<view class="G_goodsView" v-if="Product.length > 0" @click="GoodsShow = true">
				<view class="G_goodsLeft">图中包含商品（{{ Product.length }}）：</view>
				<view class="G_goodsList">
					<view class="G_goodsFor">
						<view class="G_goodsItem" v-for="(item, index) in Product" :key="index" v-if="index < 3">
							<u-image width="100%" height="100%" :src="item.main_imgurl.path" :lazy-load="true"></u-image>
						</view>
					</view>
					<view class="G_goodsIcon"><image src="../../../../static/common/icon_more.png"></image></view>
				</view>
			</view>
		</view>
		<!-- 评论 -->
		<view class="d_evaluate">
			<view class="d_eTitle">
				评论
				<text>({{ info.comment_num }})</text>
			</view>
			<view class="d_eList">
				<view v-for="(comment, index) in commentList" :key="index">
					<view class="d_eItem">
						<view class="d_eHead" v-if="comment.user_id.avatar"><image :src="comment.user_id.avatar.path"></image></view>
						<view class="d_eHead" v-else><image src="https://manager.ryz1620.com/static/my/avator.png"></image></view>
						<view class="d_eCont">
							<view @tap="dync_commentSelectReply(comment.id, comment.user_id.username)">
								<view class="d_eName">
									{{ comment.user_id.username }}
									<!-- <view class="d_eAuth">作者</view> -->
								</view>
								<view class="d_eTxt">{{ comment.content }}</view>
								<view class="d_eTxt">
									<view class="d_eTip" style="padding-left: 0;">{{ comment.createTime }}</view>
									<view class="d_eTip" @tap.top="getcommentdel(comment.id)" v-if="comment.user_id.id == useid">删除</view>
									<view class="d_eTip" v-else style="color: #333;">回复</view>
								</view>
							</view>
							<view class="d_eIts">
								<view v-for="reply in comment.sub_reply" :key="reply.id">
									<view class="d_eiItem" @tap="dync_commentSelectReply(reply.id, reply.user_id.username)">
										<view class="d_eiHead" v-if="reply.user_id.avatar"><image :src="reply.user_id.avatar.path"></image></view>
										<view class="d_eiHead" v-else><image src="https://manager.ryz1620.com/static/my/avator.png"></image></view>
										<view class="d_eiCont">
											<view class="d_eiName" v-if="reply.user_id.username">{{ reply.user_id.username }}</view>
											<view class="d_eiName" v-else>*****</view>
											<view class="d_eiTxt">
												<view v-if="reply.isReplay" style="color: #666; font-size: 20rpx;">
													回复
													<text class="d_eiReply" v-if="reply.reply_id.username">{{ reply.reply_id.username }}</text>
													<text class="d_eiReply" v-else>*****</text>
													：
												</view>
												{{ reply.content }}
											</view>
											<view class="d_eiTxt">
												<view class="d_eiTip">{{ reply.createTime }}</view>
												<view class="d_eiTip" @tap.top="getcommentdel(reply.id)" v-if="reply.user_id.id == useid">删除</view>
												<view class="d_eiTip" v-else style="color: #333;">回复</view>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 评论框 -->
		<view class="d_talk">
			<view class="d_tShim"></view>
			<view class="d_tBox">
				<view class="d_tFuns">
					<view class="d_tFun" @click="is_show_model = true">
						<view class="d_tIcon iconfont icon-transpond"></view>
						<view class="d_tTxt">转发</view>
					</view>
					<view class="d_tFun" @click="trendStore(info)">
						<view class="d_tIcon" v-if="info.support_status == 1"><image src="/static/common/icon_collection.png"></image></view>
						<view class="d_tIcon" v-else><image src="/static/common/icon_collection2.png"></image></view>
						<view class="d_tTxt">{{ info.support_num }}</view>
					</view>
				</view>
				<!-- <view class="d_tInput"><input type="text" v-model="comment" @confirm="commentAuth" placeholder="评论一下吧~" placeholder-class="placeholder"/></view> -->
				<view class="d_tInput" v-if="!commentReplyName">
					<input
						type="text"
						placeholder-class="placeholder"
						:focus="commentFocus"
						v-model="content"
						:placeholder="commentReplyName ? '回复 @' + commentReplyName + ':' : '评论一下吧~'"
						@confirm="dync_comment"
						@input="inputKey($event, 'comment')"
					/>
				</view>
				<view class="d_tInput" v-else>
					<input
						type="text"
						placeholder-class="placeholder"
						:focus="commentFocus"
						v-model="content"
						:placeholder="commentReplyName ? '回复 @' + commentReplyName + ':' : '评论一下吧~'"
						@confirm="dync_commentReply"
						@input="inputKey($event, 'comment')"
					/>
				</view>
			</view>
		</view>
		<!--模态弹窗-->
		<view class="cu-modal bottom-modal" :class="[is_show_model ? 'show' : '']" @click.stop="is_show_model = false">
			<view class="cu-dialog bottom-md" style="border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;" @click.stop="">
				<view class="md-content">
					<view class="md-content-item">
						<view class="s_bIcon iconfont icon-friend"></view>
						<view>分享给好友</view>
						<!-- #ifdef MP-WEIXIN -->
						<button open-type="share" @click="is_show_model = false" class="sharebtn"></button>
						<!-- #endif -->
						<!-- #ifdef APP-PLUS-->
						<button @click="actionsheettip" class="sharebtn"></button>
						<!-- #endif -->
					</view>
					<view class="md-content-item" @click="popShareToPicture">
						<view class="s_bIcon s_bIcons iconfont icon-picture"></view>
						<view>生成分享大图</view>
					</view>
				</view>
				<view class="cancel" @click="is_show_model = false">取消</view>
			</view>
		</view>
		<!-- 商品框 -->
		<u-popup id="popupView" v-model="GoodsShow" height="1000" mode="bottom" border-radius="14" :closeable="true" :safe-area-inset-bottom="true" style="position: relative;">
			<view>
				<view class="popupTitle">图中包含商品</view>
				<view class="ScrollList">
					<view class="ListItem" v-for="(item, index) in Product" :key="index" @click="toProduct(item.id)">
						<view class="listLeft">
							<view class="ListImage"><image :src="item.main_imgurl.path"></image></view>
							<view style="flex: 1;">
								<view class="ListTitle TextLenght">{{ item.product_title }}</view>
								<view class="ListShop">{{ item.store_name }}</view>
								<view class="ListPirce">¥{{ item.price }}</view>
							</view>
						</view>
						<text class="iconfont icon-more" style="font-size: 30rpx;font-weight: bold;color: #CCCCCC;"></text>
					</view>
				</view>
			</view>
		</u-popup>
		<view class="goodschat">
			<view class="i_tBtn">
				<!-- #ifndef MP-WEIXIN -->
				<view class="i_tbIcon" @click="gitchat()">
					<text class="iconfont iconhuaban110"></text>
					<text>客服</text>
				</view>
				<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<view class="i_tbIcon" @click="gitchat()"  v-if="!config_id && !config_url">
					<text class="iconfont iconhuaban110"></text>
					<text>客服</text>
				</view>
				<view class="i_tbIcon" v-else @click="gitpouchatshow">
					<text class="iconfont iconhuaban110"></text>
					<text>客服</text>
				</view>
				<!-- #endif -->
			</view>
		</view>
		<!-- #ifdef MP-WEIXIN -->
		<view class="timline" v-if="Timeline" @click="gittimeline()">
			<view class="conty">
				<view class="contys">
					<text>我知道了</text>
					<image src="https://manager.ryz1620.com/static/my/sharechat.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
		<!-- #endif -->
		<!-- 微信客服 -->
		<view class="pouchat" v-if="pouchatshow">
		  <view class="poucont">	
			<view class="chatlist">
				<view class="chatml" @click="gitwxchat()" v-if="config_url">
					<image src="https://manager.ryz1620.com/static/my/wxchat.png" mode="widthFix"></image>
					<text class="t1">在线微信客服</text>
					<text class="t2">可直接联系客服</text>
				</view>
				<view class="chatml" v-if="config_id">
					<cell class="cell-service" bind:startmessage='startmessage' bind:completemessage="completemessage" :plugid="config_id"/>
					<image src="https://manager.ryz1620.com/static/my/codechat.png" mode="widthFix"></image>
					<text class="t1">添加微信客服</text>
					<text class="t2">扫微信二维码</text>
				</view>
			</view>
			<view class="iconfont icon-close" @click="wxCodeClick"></view>
		  </view>	
		</view>
	</view>
</template>

<script>
// import navBar from "@/components/navBar/navBar"
import service_design from '@/service/design';
import service_mall from '@/service/mall.js';
import $HTTPS from '@/service/DIY.js';
export default {
	components: {
		// #ifdef MP-WEIXIN
			"cell": "plugin://contactPlugin/cell",
		// #endif
	},
	data() {
		return {
			info: {},
			userdata: '',
			media: [],
			isSupport: false,
			// 分享弹窗
			popShare: false,
			// 评论
			commentPage: 0,
			commentTime: 0,
			commentList: [],
			comment: '',
			replyId: null,
			content: '',
			useid: '',
			commentIsReply: false,
			commentLoading: false,
			commentReplyId: '',
			commentReplyName: '',
			// 轮播图
			bannerIndex: 0,
			bannerCurrent: 0,
			trend_id: null,
			create_time: '',
			userId: '',
			commentFocus: false,
			is_show_model: false, //是否显示分享模态窗
			Product: [],
			GoodsShow: false,
			isFocus: 0,
			config_id:'',
			config_url:'',
			pouchatshow:false,
			forward_id:0,//转发id
			forwardImg:'',
			Timeline:false,
			LineShareforward: null,
		};
	},
	components: {
		// navBar
	},
	onLoad(params) {
		const that = this;
		that.$utils.getUrl()
		that.gitConfig()
		that.gitwxConfig()
		//#ifdef MP-WEIXIN
		let pages = wx.getLaunchOptionsSync()
		//#endif
		// #ifdef APP-PLUS || H5
		let pages = ''
		// #endif
		if(params.Timeline && pages.scene == '1154'){
			that.Timeline = true
		}
		let scene = decodeURIComponent(params.scene);
		let token = uni.getStorageSync('token');
		scene = scene.split('&');
		let obj = {};
		for (let i = 0; i < scene.length; i++) {
			let newscene = scene[i].split('=');
			obj[newscene[0]] = newscene[1];
		}
		// 分享动态的时候二维码参数过长时 二次获取二维码参数
		if(obj.scene){
			console.log(obj.scene,'扫小程序码的参数')
			that.getShareData(obj)
		}
		
		if (obj.trendId) {
			that.trend_id = obj.trendId;
			that.getDetail();
		} else {
			that.trend_id = params.trendId;
			that.getDetail();
		}
		console.log(obj,params,'转发过来的参数')
		if(obj.forward_id){
			that.forward_id = obj.forward_id
		}else{
			that.forward_id = params.forward_id
		}
		if (params.share_uid) {
			console.log('share')
			let shareuId = params.share_uid;
			that.$store.commit('index/SET_shareuId', shareuId);
			if (token && shareuId) {
				service_mall
					.getPromoter({
						share_uid: shareuId
					})
					.then(res => {
					});
			}
		}
		if (obj.share_uid) {
			let shareuId = obj.share_uid;
			that.$store.commit('index/SET_shareuId', shareuId);
			if (token && shareuId) {
				service_mall
					.getPromoter({
						share_uid: shareuId
					})
					.then(res => {
					});
			}
		}
		if(!obj.scene){
			that.dyna_getComment();
			that.getTrendTracet();
		}
		that.userId = uni.getStorageSync('userId');
	},
	onShow(options) {
		let token = uni.getStorageSync('token');
		let shareuId = this.$store.state.index.shareuId
		if (token && shareuId) {
			service_mall.getPromoter({ share_uid: shareuId }).then(res => {
			});
		}
	},
	filters: {
		formatDate(value) {
			let date = new Date(parseInt(value) * 1000);
			let y = date.getFullYear();
			let m = date.getMonth() + 1;
			m = m < 10 ? '0' + m : m;
			let d = date.getDate();
			d = d < 10 ? '0' + d : d;
			let h = date.getHours();
			h = h < 10 ? '0' + h : h;
			let minute = date.getMinutes();
			let second = date.getSeconds();
			minute = minute < 10 ? '0' + minute : minute;
			second = second < 10 ? '0' + second : second;
			return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
		}
	},
	onShareAppMessage(res) {
		uni.showShareMenu({
		  withShareTicket: true,
		  menus: ['shareAppMessage', 'shareTimeline']
		})
		let that = this;
		if (res.from === 'button') {
		}
		// that.getgetforwards();
		// return {
		// 	title: this.info.title,
		// 	path: '/pages_design/pages/design/dynamic/dynamic?trendId=' + this.trend_id + '&share_uid=' + this.userId + '&forward_id=' + this.forward_id,
		// 	success: function(res) {
				
		// 	}
		// };
		return new Promise((resolve, reject) => {
			service_design
				.gettrends({
					trend_id: this.trend_id
				})
				.then(res => {
					if (res.code == 1) {
						console.log(res.data.forward_id);
						resolve({
							title: this.info.title,
							path: '/pages_design/pages/design/dynamic/dynamic?trendId=' + this.trend_id + '&share_uid=' + this.userId + '&forward_id=' + res.data.forward_id,
							imageUrl: this.forwardImg
						});
					}
				});
		});
	},
	onShareTimeline(res) {
		let that = this;
		service_design
			.gettrends({
				trend_id: that.trend_id
			})
			.then(res => {
				if (res.code == 1) {
					var forward_id = res.data.forward_id;
					that.LineShareforward = forward_id;
				}
		});
		if (res.from === 'menu') {
     
		}return {
			title: this.info.title,
			path: '/pages_design/pages/design/dynamic/dynamic?trendId=' + this.trend_id + '&share_uid=' + this.userId + '&forward_id=' + this.LineShareforward + '&Timeline=1',
			imageUrl: this.forwardImg,
			success: function(res) {
			}
		};
	},
	methods: {
		gittimeline(){
			this.Timeline = false
		},
		
		// 二维码参数过长 获取二维码参数
		async getShareData(obj){
			const that = this
			let token = uni.getStorageSync('token');
			let res = await service_design.getShareQrParams({scene:obj.scene})
			console.log(res,'获取的微信小程序码的参数')
			if(res.code==1){
				console.log('987070kajsdjk')
				that.forward_id = res.data.forward_id;
				that.trend_id = res.data.target_id;
				console.log(that.forward_id,that.trend_id)
				that.getDetail();
				that.dyna_getComment();
				that.getTrendTracet();
				let shareuId = res.data.share_uid;
				that.$store.commit('index/SET_shareuId', shareuId);
				if (token && shareuId) {
					let rest = await service_mall.getPromoter({share_uid: shareuId})
				}
			}
		},
		
		
		// 预览图片
		preview(index, urls) {
			let img_url = [];
			for (let i = 0; i < urls.length; i++) {
				img_url.push(urls[i].path);
			}
			uni.previewImage({
				urls: img_url,
				current: index,
				longPressActions: {
					itemList: ['发送给朋友', '保存图片', '收藏'],
					success: function(data) {
						console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
					},
					fail: function(err) {
						console.log(err.errMsg);
					}
				}
			});
		},
		// 转发按钮
		// forwardBtn(){
		// 	this.is_show_model = true
		// 	this.getgetforwards()
		// },
		
		// app分享
		actionsheettip() {
			let title = this.info.title;
			let imageUrl = this.media[0].path;
			let path = 'pages_design/pages/design/dynamic/dynamic?trendId=' + this.trend_id + '&share_uid=' + this.userId + '&forward_id=' + this.forward_id;
			let that = this;
			// 压缩图片 图文分享要求分享图片大小不能超过20Kb
			uni.downloadFile({
				url: imageUrl,
				success: res => {
					if (res.statusCode === 200) {
						uni.compressImage({
							src: res.tempFilePath,
							quality: 25,
							success: ress => {
								var tempFilePath = ress.tempFilePath;
								that.$common.appShare(title, tempFilePath, path, result => {
									if (result == 'success') {
										that.getgetforwards();
									}
								});
							}
						});
					}
				}
			});
		},
		toPageurl(storeId) {
			// uni.navigateTo({
			// 	url: '/pages_mall/pages/mall/store/store?storeId=' + store_id
			// });
			var that = this;
			$HTTPS
				.GetDiyData({
					partner_id: storeId
				})
				.then(res => {
					if (res.code == 1) {
						let data = res.data;
						console.log(data);
						if (data.content) {
							uni.navigateTo({ url: '/pages_mall/pages/Decoration/view/index?storeId=' + storeId });
						} else {
							uni.navigateTo({ url: '/pages_mall/pages/mall/store/storeNew?storeId=' + storeId });
						}
					} else {
						that.$utils.showErr({
							title: res.msg
						});
					}
				})
				.catch(err => {
					that.$utils.showErr({
						title: err
					});
				});
		},
		toProduct(product_id) {
			uni.navigateTo({
				url: '/pages_mall/pages/mall/goods_details/goods_details?id=' + product_id
			});
		},
		FollowUser(follow_id) {
			let follow = this.isFocus
			if (follow != 0) {
				uni.showModal({
					title: '提示',
					content: '确认取消关注?',
					success: res => {
						if (res.confirm) {
							service_design
								.GetFollow({
									follow_user_id: follow_id,
									status: 0
								})
								.then(res => {
									if (res.code == 1) {
										this.isFocus = 0;
									} else {
										this.$utils.showErr({
											title: res.msg
										});
									}
								});
						} else if (res.cancel) {
							return;
						}
					}
				});
			} else {
				service_design
					.GetFollow({
						follow_user_id: follow_id,
						status: 1
					})
					.then(res => {
						if (res.code == 1) {
							this.isFocus = 1
							wx.showToast({
							  title: '关注成功',
							  icon: 'success',
							  duration: 2000
							})
						} else {
							this.$utils.showErr({
								title: res.msg
							});
						}
					});
			}
		},
		// 获取详情数据
		async getDetail() {
			let res = await service_design.getDyncDetail({trend_id: this.trend_id})
				if (res.code == 1) {
					let data = res.data;
					this.info = data;
					this.userdata = data.user_id;
					this.media = data.media;
					this.create_time = data.create_time;
					this.forwardImg = data.type==1?data.media[0].cover:data.media[0].path
					this.getProduct();
				}
		},
		getProduct() {
			service_design
				.getProductList({
					trend_id: this.trend_id
				})
				.then(res => {
					if (res.code == 1) {
						let data = res.data;
						console.log(data);
						this.Product = data;
					}
				});
		},
		// 转发
		// getgetforwards() {
		// 	service_design
		// 		.gettrends({
		// 			trend_id: this.trend_id
		// 		})
		// 		.then(res => {
		// 			console.log(res,'转发id')
		// 			if(res.code==1){
		// 				 this.forward_id = res.data.forward_id
		// 			}
		// 		});
		// },
		// 记录足迹
		async getTrendTracet() {
			const that = this;
			console.log(that.trend_id,that.forward_id,'记录足迹时动态id与转发id')
			let res = await service_design.getTrendTracetrace({trend_id: that.trend_id,forward_id:that.forward_id?that.forward_id:0})
				console.log(that.trend_id,that.forward_id,res,'记录足迹')
		},
		// 动态点赞
		trendStore(item) {
			let status = item.support_status;
			if (status == 1) {
				uni.showModal({
					title: '提示',
					content: '确认取消点赞?',
					success: res => {
						if (res.confirm) {
							service_design
								.gitTrendstatus({
									trend_id: item.id,
									status: 0
								})
								.then(res => {
									if (res.code == 1) {
										this.info.support_status = 0;
										this.info.support_num--;
									} else {
										this.$utils.showErr({
											title: res.msg
										});
									}
								});
						} else if (res.cancel) {
							return;
						}
					}
				});
			} else {
				service_design
					.gitTrendstatus({
						trend_id: item.id,
						status: 1
					})
					.then(res => {
						if (res.code == 1) {
							this.info.support_status = 1;
							this.info.support_num++;
						} else {
							this.$utils.showErr({
								title: res.msg
							});
						}
					});
			}
		},
		// 输入框输入内容事件
		inputKey(event, key) {
			this[key] = event.detail.value;
		},
		moveHandle() {},
		// 获取设计动态的评价内容
		dyna_getComment() {
			this.commentTime++;
			let commentTime = this.commentTime;
			let commentPage = this.commentPage + 1;
			// 获取评论数据
			service_design
				.getCommentList({
					trend_id: this.trend_id,
					page: commentPage
				})
				.then(res => {
					if (this.commentTime === commentTime) {
						if (res.code == 1) {
							let data = res.data;
							let list = this.v || [];
							// 处理数据
							let nowTime = Date.now();

							for (let i = 0; i < data.length; i++) {
								data[i].create_time *= 1000;
								data[i].createTime = this.$utils.getDateDiff(data[i].create_time);
								// 处理回复数据
								let replayList = data[i].sub_reply;
								if (replayList && replayList.length) {
									for (let j = 0; j < replayList.length; j++) {
										replayList[j].create_time *= 1000;
										replayList[j].createTime = this.$utils.getDateDiff(replayList[j].create_time);

										// 是否是回复 回复数据 的数据
										if (data[i].id !== replayList[j].parent_id) replayList[j].isReplay = true;
									}
								}
								// 保存数据
								list.push(data[i]);
							}

							this.commentPage++;
							this.commentList = list;
						}
					}
				})
				.catch(err => {
					if (this.commentTime === commentTime) {
						this.commentLoading = false;
					}
				});
		},
		// 评论
		dync_comment() {
			let content = this.content;
			service_design
				.getcomment({
					trend_id: this.trend_id,
					content: content
				})
				.then(res => {
					if (res.code == 1) {
						this.TrendPage = 0;
						this.commentPage = 0;
						this.commentList = [];
						this.trend_idnum++;
						this.content = '';
						this.dyna_getComment();
						this.getDetail();
					}
				})
				.catch(err => {});
		},
		// 回复他人评论
		dync_commentSelectReply(id, name) {
			this.commentIsReply = true;
			this.commentReplyId = id;
			this.commentReplyName = name;
			this.content = '';
		},
		// 发布回复评论
		dync_commentReply() {
			service_design
				.getcommentreply({
					comment_id: this.commentReplyId,
					content: this.content
				})
				.then(res => {
					if (res.code == 1) {
						this.commentIsReply = false;
						this.commentPage = 0;
						this.commentList = [];
						this.content = '';
						this.commentReplyId = '';
						this.commentReplyName = '';
						this.dyna_getComment();
					}
				})
				.catch(err => {});
		},
		// 获取更多评论内容
		dync_commentNext(e) {
			this.dyna_getComment();
		},
		// 删除评论
		getcommentdel(id) {
			uni.showModal({
				title: '提示',
				content: '确认删除评论?',
				success: res => {
					if (res.confirm) {
						service_design
							.getcommentdel({
								comment_id: id
							})
							.then(res => {
								if (res.code == 1) {
									this.TrendPage = 0;
									this.commentPage = 0;
									this.commentList = [];
									this.trend_idnum--;
									this.content = '';
									this.dyna_getComment();
									this.getTrend();
								} else {
									this.$utils.showErr({
										title: res.msg
									});
								}
							});
					} else if (res.cancel) {
						return;
					}
				}
			});
		},
		// 轮播图
		bannerChange(e) {
			this.bannerIndex = e.detail.current;
			//动态设置swiper的高度，使用nextTick延时设置
			this.$nextTick(() => {
						this.setSwiperHeight();
			});
		},

		// 弹窗-分享==
		// 关闭弹窗
		popShareClose() {
			this.popShare = false;
		},
		// 跳转-海报页面
		popShareToPicture() {
			uni.navigateTo({
				url: '/pages_design/pages/design/dynamic/share?trendId=' + this.trend_id
			});
		},
		// 客服
		gitchat() {
			uni.showToast({
				title: '哎呀!不好意思，暂未配置客服...',
				icon: 'none',
				duration: 2000
			});
			// let token = uni.getStorageSync('token')
			// if (token) {
			// 	uni.navigateTo({
			// 		url: "/pages_customer/pages/index?partner_type=root&partner_id=0"
			// 	})
			// } else {
			// 	uni.showModal({
			// 		title: "提示！",
			// 		content: "请先登录！",
			// 		success: function(s) {
			// 			if (s.confirm) {
			// 				uni.navigateTo({
			// 					url: '/pages_login/pages/login/login/index',
			// 				});
			// 			}
			// 		}
			// 	});
			// }
		},
		// 获取企业微信callme配置
		gitConfig() {
			service_mall.getCallMeConfig({ partner_type: 'root', partner_id: 1 }).then(res => {
				if (res.code == 1) {
					this.config_id = res.data.config_id;
				}
			});
		},
		gitwxConfig() {
			service_mall.getwxMeConfig({ partner_type: 'root', partner_id: 1 }).then(res => {
				if (res.code == 1) {
					this.config_url = res.data.url;
				}
			});
		},
		gitpouchatshow(){
			this.pouchatshow = true
		},
		wxCodeClick(){
			this.pouchatshow = false
		},
		gitwxchat(){
			wx.openCustomerServiceChat({
			  extInfo: {url: this.config_url},
			  corpId: this.$env.CORPID,
			  success(res) {}
			})
		},
	}
};
</script>

<style lang="scss" scoped>
// 顶部作者栏=====
.dynamic .d_auth {
	position: relative;
	z-index: 100;
}
.popupTitle {
	font-size: 32rpx;
	font-weight: 500;
	color: #0a0605;
	text-align: center;
	position: fixed;
	width: 100%;
	background: #fff;
	top: 0;
	padding: 34rpx 0 10rpx 0;
	z-index: 1;
}
.TextLenght {
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
}

.TextLenghtTwo {
	text-overflow: -o-ellipsis-lastline;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.ScrollList {
	background: #fff;
	margin-top: 54rpx;
	padding: 50rpx 32rpx 32rpx 32rpx;

	.ListItem {
		box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.06);
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		padding: 28rpx;
		justify-content: space-between;
		margin-bottom: 40rpx;
		.listLeft {
			display: flex;
			align-items: center;
			.ListImage {
				width: 124rpx;
				height: 124rpx;
				overflow: hidden;
				border-radius: 8rpx;
				margin-right: 16rpx;
			}
			.ListTitle {
				font-size: 26rpx;
				font-weight: 500;
				color: #505050;
				flex: 1;
				margin-bottom: 14rpx;
			}
			.ListShop {
				font-size: 22rpx;
				font-weight: 400;
				color: #c3ab7c;
				margin-bottom: 6rpx;
				padding: 2rpx 8rpx;
				background: rgba(195, 171, 124, 0.1);
				border-radius: 4rpx;
				width: max-content;
			}
			.ListPirce {
				font-size: 22rpx;
				font-weight: 400;
				color: #e5675a;
			}
		}
	}
}
.dynamic .d_auth .d_aCan {
	overflow: hidden;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.dynamic .d_auth .d_aFocus {
	width: 114rpx;
	height: 48rpx;
	line-height: 48rpx;
	text-align: center;
	color: #fff;
	font-size: 20rpx;
	margin: 0 36rpx 0 40rpx;
	border-radius: 28rpx;
	background: #333;
	float: right;
}

.dynamic .d_auth .d_aHead {
	width: 68rpx;
	height: 68rpx;
	margin: 0 28rpx 0 32rpx;
	border-radius: 50%;
	background: #f0f0f0;
	overflow: hidden;
	float: left;
}
.d_guanzhu {
	border-radius: 48rpx;
	font-size: 26rpx;
	font-weight: 500;
	padding: 12rpx 30rpx;
	margin-left: 30rpx;
	margin-right: 60rpx;
}
.dynamic .d_auth .d_aName {
	height: 40rpx;
	line-height: 40rpx;
	overflow: hidden;
	flex: 1;
}

// banner=====
.dynamic .d_banner {
	// width: 100vw;
	height: 700rpx;
	// padding-top: 20rpx;
	background: #fff;
	position: relative;
	// z-index: 99;
}

.g_bDots {
	width: 100%;
	position: absolute;
	bottom: 20rpx;
	left: 0;
	display: flex;
	justify-content: center;
}

.g_bDot {
	padding: 16rpx 8rpx;
	.g_bIcon {
		width: 12rpx;
		height: 12rpx;
		border-radius: 100%;
		background: rgba(255, 255, 255, 0.5);
	}
	&.active .g_bIcon {
		background: #ffd425;
	}
}

.g_bIcon {
	width: 10rpx;
	height: 10rpx;
	border-radius: 50%;
	background: rgba(26, 28, 32, 0.4);
}

.dynamic .d_banner .d_bSwiper {
	width: 100%;
	height: 100%;
}

.dynamic .d_banner .d_bItem {
	width: 100%;
	height:100%;
	background: #f0f0f0;
}

.dynamic .d_banner .d_bTip {
	width: 80rpx;
	height: 52rpx;
	line-height: 52rpx;
	text-align: center;
	color: #fff;
	font-size: 24rpx;
	border-radius: 28rpx;
	background: #333;
	opacity: 0.8;
	position: absolute;
	top: 40rpx;
	right: 32rpx;
	z-index: 10;
}
.S_stop {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 32rpx;
	border-bottom: 1px solid #f5f5f5;
	padding-bottom: 15rpx;
	.S_Head {
		padding-top: 32rpx;
		display: flex;
		align-items: center;
		.S_Image {
			width: 52rpx;
			height: 52rpx;
			border-radius: 50%;
			overflow: hidden;
		}
		.S_stopName {
			font-size: 26rpx;
			font-weight: 500;
			color: #666666;
			margin-left: 20rpx;
		}
	}
	.iconfont {
		margin-top: 18px;
		color: #a1a1a1;
	}
}
.S_title {
	font-size: 34rpx;
	font-weight: bold;
	color: #2c2c2c;
	padding: 32rpx 32rpx 0 32rpx;
}
.G_goodsView {
	margin: 32rpx 32rpx 0 32rpx;
	background: #f6f7fb;
	border-radius: 10rpx;
	padding: 22rpx 32rpx;
	display: flex;
	align-items: center;
	.G_goodsLeft {
		font-size: 28rpx;
		font-weight: bold;
		color: #2b2b2b;
		margin-right: 30rpx;
		flex: 1;
	}
	.G_goodsList {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex: 1;
		.G_goodsFor {
			display: flex;
			align-items: center;
			.G_goodsItem {
				width: 66rpx;
				height: 66rpx;
				overflow: hidden;
				border-radius: 4rpx;
				margin-right: 24rpx;
			}
		}
		.G_goodsIcon {
			width: 36rpx;
			height: 36rpx;
			overflow: hidden;
			border-radius: 4rpx;
		}
	}
}
// 内容=====
.dynamic .d_content {
	padding-bottom: 40rpx;
	background: #fff;
	position: relative;

	&::after {
		content: '';
		height: 1px;
		background: #f4f4f4;
		position: absolute;
		bottom: 0;
		left: 32rpx;
		right: 32rpx;
	}
}

.dynamic .d_content .d_cTags {
	padding: 20rpx 32rpx 0;
	overflow: hidden;
}

.dynamic .d_content .d_cTag {
	height: 44px;
	height: 44rpx;
	line-height: 44rpx;
	color: #a58f6d;
	font-size: 24rpx;
	padding-left: 48rpx;
	padding-right: 20rpx;
	margin: 8rpx 8rpx 0 0;
	border-radius: 22rpx;
	background: #f9f6f3;
	position: relative;
	float: left;
}

.dynamic .d_content .d_cIcon {
	width: 36rpx;
	height: 36rpx;
	position: absolute;
	top: 4rpx;
	left: 4rpx;
}

.dynamic .d_content .d_cText {
	line-height: 44rpx;
	margin: 16rpx 36rpx 0;
}

.dynamic .d_content .d_cTime {
	height: 34rpx;
	line-height: 34rpx;
	color: #939393;
	font-size: 24rpx;
	margin: 16rpx 0 0 36rpx;
}

// 评论=====
.dynamic .d_evaluate {
	padding: 28rpx 0;
	background: #fff;
}

.dynamic .d_evaluate .d_eTitle {
	height: 50rpx;
	line-height: 50rpx;
	font-size: 36rpx;
	font-weight: bold;
	padding-left: 36rpx;

	& > text {
		font-size: 24rpx;
		font-weight: bold;
		padding-left: 8rpx;
	}
}

.dynamic .d_evaluate .d_eList {
	padding-left: 32rpx;
}

.dynamic .d_evaluate .d_eItem {
	margin-top: 30rpx;

	&:nth-last-child(1) .d_eCont::after {
		content: none;
	}
}

.dynamic .d_evaluate .d_eHead,
.dynamic .d_evaluate .d_eIts .d_eiHead {
	width: 66rpx;
	height: 66rpx;
	margin-right: 16rpx;
	border-radius: 50%;
	background: #f0f0f0;
	float: left;
}

.dynamic .d_evaluate .d_eCont {
	padding-bottom: 28rpx;
	position: relative;
	overflow: hidden;

	&::after {
		content: '';
		width: 100%;
		height: 1px;
		background: #f4f4f4;
		position: absolute;
		bottom: 0;
		left: 0;
		transform: scaleY(0.5);
	}
}

.dynamic .d_evaluate .d_eName,
.dynamic .d_evaluate .d_eIts .d_eiName {
	height: 28rpx;
	line-height: 28rpx;
	color: #939393;
	font-size: 20rpx;
}

.dynamic .d_evaluate .d_eAuth,
.dynamic .d_evaluate .d_eIts .d_eiAuth {
	width: 64rpx;
	height: 28rpx;
	line-height: 28rpx;
	text-align: center;
	color: #333;
	font-size: 20rpx;
	margin-left: 8rpx;
	border-radius: 28rpx;
	background: #f6f7fb;
	display: inline-block;
}

.dynamic .d_evaluate .d_eTxt,
.dynamic .d_evaluate .d_eIts .d_eiTxt {
	min-height: 34rpx;
	line-height: 34rpx;
	font-size: 24rpx;
	padding-right: 32rpx;
	margin-top: 4rpx;
}

.dynamic .d_evaluate .d_eTip,
.dynamic .d_evaluate .d_eIts .d_eiTip {
	color: #939393;
	font-size: 20rpx;
	padding-left: 16rpx;
	display: inline-block;
}

// 他人回复
.dynamic .d_evaluate .d_eiItem {
	margin-top: 16rpx;
}

.dynamic .d_evaluate .d_eiCont {
	overflow: hidden;
}

.dynamic .d_evaluate .d_eiReply {
	color: #939393;
	font-size: 20rpx;
	padding: 0 4rpx;
}

// 评论框=====
.dynamic .d_talk {
	.d_tShim {
		height: 96rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}

	.d_tBox {
		width: 100vw;
		height: 96rpx;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		box-shadow: 0 0 12rpx 0 rgba(155, 155, 155, 0.16);
	}

	.d_tFuns {
		padding-left: 30rpx;
		float: right;
	}

	.d_tFun {
		width: 110rpx;
		height: 96rpx;
		float: right;
	}

	.d_tIcon {
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		color: #6c6c6c;
		font-size: 40rpx;
		margin: 0 auto;
		padding-top: 14rpx;
		box-sizing: content-box;
	}

	.d_tTxt {
		height: 28rpx;
		line-height: 28rpx;
		text-align: center;
		color: #939393;
		font-size: 20rpx;
	}

	.d_tInput {
		height: 60rpx;
		margin: 20rpx 0 0 32rpx;
		border-radius: 60rpx;
		overflow: hidden;

		& > input {
			width: 100%;
			height: 100%;
			font-size: 24rpx;
			padding: 0 28rpx;
			background: #f6f7fb;
		}
	}
}

.cu-modal {
	position: fixed;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	top: 0;
	display: none;
	width: 100%;
	z-index: 500;
}

.show {
	display: block;
}

.bottom-md {
	position: absolute;
	bottom: 0;
	background: #fff;
}

.share {
	position: fixed;
	color: #ffffff;
	right: 0;
	bottom: 190rpx;
	background: linear-gradient(to bottom right, #fe726b, #fe956b);
	padding: 10rpx 10rpx 10rpx 20rpx;
	border-top-left-radius: 50px;
	border-bottom-left-radius: 50px;
	box-shadow: 0 0 20upx rgba(0, 0, 0, 0.09);
}

.cancel {
	width: 100vw;
	padding: 30rpx;
	text-align: center;
	background: #ffffff;
	color: #888;
	font-weight: normal;
	font-size: 30rpx;
}

.md-content {
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	padding: 50rpx 0;
}

.md-content-item {
	margin: 0 90rpx;
	position: relative;
}

.md-content-item image {
	width: 100rpx;
	height: 100rpx;
	margin: auto;
}

.md-content-item view {
	margin-top: 15rpx;
	font-size: 28rpx;
}

.sharebtn {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	opacity: 0;
}

.md-content-item .s_bIcon {
	font-size: 72rpx;
}

.s_bIcon {
	width: 112rpx;
	height: 112rpx;
	color: #fff;
	font-size: 140rpx;
	margin: 60rpx auto 0;
	border-radius: 50%;
	background: #8bc37a;
	box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.16);
	display: flex;
	justify-content: center;
	align-items: center;
}

.s_bIcons {
	background: #ffd425;
}
.goodschat{
	position: fixed;
	right: 30rpx;
	bottom:20%;
	width: 100rpx;
	border-radius: 50%;
	height: 100rpx;
	background: rgba(255, 255, 255, 0.32);
	border:1px #dedede solid;
	z-index: 3;
	.i_tbIcon text{
		font-size: 22rpx;
		display: block;
		text-align: center;
		color: #999;
	}
	.i_tbIcon .iconfont{
		font-size: 36rpx;
		line-height: 60rpx;
	}
}
// 客服弹框
	.pouchat{
		position: fixed;
		background: rgba(0,0,0,0.5);
		top:0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 9999;
		.poucont{
			position: absolute;
			top:30%;
			left: 15%;
			right: 15%;
			.icon-close{
				width: 80rpx;
				height: 80rpx;
				font-size: 70rpx;
				color: #fff;
				line-height: 80rpx;
				text-align: center;
				margin: 30rpx auto;
			}
		}
		.chatlist{
			background: #fff;
			padding:30rpx;
			border-radius: 10rpx;
		}
		.chatml{
			position: relative;
			padding: 20rpx;
			padding-left: 100rpx;
			min-height: 100rpx;
			.cell-service{
				position: absolute;
				right: 0;
				bottom: 0;
				left: 0;
				top: 0;
				opacity: 0;
				z-index: 10;
				.cell--bubble{
					width: 100%;
				}
			}
			text{
				display: block;
				line-height: 40rpx;
			}
			.t1{
				font-size: 32rpx;
			}
			.t2{
				font-size: 24rpx;
				color: #999;
			}
			image{
				width: 70rpx;
				height: 70rpx;
				position: absolute;
				left: 15rpx;
				top:25rpx;
			}
		}
	}
.timline{
	position: fixed;
	top: 0;
	bottom:0;
	left: 0;
	right: 0;
	background: rgba(0,0,0,0.6);
	z-index: 999;
	.conty{
		position: absolute;
		bottom:20rpx;
		left: 0;
		width: 100%;
		.contys{
			text{
				display: block;
				width: 160rpx;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				margin: 20rpx auto;
				border:1px #fff solid;
				background: rgba(255,255,255,0.2);
				color: #fff;
				border-radius: 10rpx;
			}
			image{
				display: block;
				margin: auto;
				width: 55%;
			}
		}
	}
}	
</style>
